﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WeChartWorkRobot.Model;
using WeChartWorkRobot.Model.DTO;

namespace WeChartWorkRobot.Service
{
    public class SendMsg
    {
        public static void SendTextMsg(WxMsg wxMsg)
        {
            if (string.IsNullOrEmpty(wxMsg.robot_url))
            {
                throw new Exception("robot_url is empty");
            }
            MyHttpRequest myHttpRequest = new MyHttpRequest(wxMsg.robot_url);
            myHttpRequest.Post<object>(new TextMsgDTO { text = wxMsg });
        }

        public static void SendMarkDownMsg(WxMsg wxMsg)
        {
            if (string.IsNullOrEmpty(wxMsg.robot_url))
            {
                throw new Exception("robot_url is empty");
            }
            MyHttpRequest myHttpRequest = new MyHttpRequest(wxMsg.robot_url);
            myHttpRequest.Post<object>(new MarkDownMsg { markdown = wxMsg });
        }
    }
}
